package pub.atps.example.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import pub.tbc.toolkit.collection.MapBuilder;

import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @author tbc on 2016/12/1 20:51.
 */
@RestController
public class Controller {

    /**
     * 模拟普通任务，100毫秒
     *
     * @return
     * @throws InterruptedException
     */
    @GetMapping("demo1")
    public Map<String, Object> demo1() throws InterruptedException {
        TimeUnit.MICROSECONDS.sleep(100);
        return new MapBuilder<String, Object>().put("kk", "vv").build();
    }

    /**
     * 模拟耗时任务，5秒
     *
     * @return
     * @throws InterruptedException
     */
    @GetMapping("demo2")
    public Map<String, Object> demo2() throws InterruptedException {
        TimeUnit.SECONDS.sleep(2);
        return new MapBuilder<String, Object>().put("kkk", "vvv").build();
    }

}
